package airlinesystem;

import java.sql.Time;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

/**
 * Represents an airline
 * @author Robert Maaskant & Dennis van der Zwet
 *
 */
public class Airline
{
  /**
   * The name of the airline
   */
  private String name;
  
  /**
   * The RegularFlight's provided by this airline
   */
  private Set<RegularFlight> regularFlights;
  
  /**
   * Constructor for Airline  
   * @param name the name of the airline
   */
  public Airline(String name)
  {
    this.name = name;
    regularFlights = new HashSet<RegularFlight>();
  }

  /**
   * Returns the name of the airline.
   * @return the name of the airline
   */
  public String getName()
  {
    return name;
  }
  
  /**
   * Creates a booking for p with f
   * @param p the passenger booking the flight
   * @param f the flight being booked
   */
  public Booking createBooking(PassengerRole p, SpecificFlight f)
  {
    return new Booking(p, f, f.getNextSeatNumber());
  }
  
  /**
   * Create a regular flight
   * @param flightNumber
   * @param time
   */
  public RegularFlight createRegularFlight(Time time, int flightNumber)
  {
    RegularFlight r = new RegularFlight(this, time, flightNumber);
    regularFlights.add(r);
    return r;
  }
  
  /**
   * Creates a specific flight implementing f at date d
   * @param d the date this flight departs
   * @param f the RegularFlight to implement
   */
  public SpecificFlight createSpecificFlight(Date d, RegularFlight f)
  {
    return new SpecificFlight(d, f);
  }
  
  public Set<Booking> findBookingsByPassenger(PassengerRole p)
  {
    return p.getBookings();
  }
  
  public Set<SpecificFlight> findFlightsByEmployee(EmployeeRole e)
  {
    return e.getFlights();
  }

}
